package com.ruoyi.monitor.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.monitor.domain.MonitorPart;
import com.ruoyi.monitor.service.IMonitorPartService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 局部热处理实时数据Controller
 * 
 * @author ruoyi
 * @date 2023-02-12
 */
@Controller
@RequestMapping("/monitor/part")
public class MonitorPartController extends BaseController
{
    private String prefix = "monitor/part";

    @Autowired
    private IMonitorPartService monitorPartService;

    @RequiresPermissions("monitor:part:view")
    @GetMapping()
    public String part()
    {
        return prefix + "/part";
    }


    @GetMapping("/dynamic")
    public String dynamic() {
        return prefix + "/dynamic";
    }

    /**
     * 查询局部热处理实时数据列表
     */
    @RequiresPermissions("monitor:part:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MonitorPart monitorPart)
    {
        startPage();
        List<MonitorPart> list = monitorPartService.selectMonitorPartList(monitorPart);
        return getDataTable(list);
    }

    /**
     * 导出局部热处理实时数据列表
     */
    @RequiresPermissions("monitor:part:export")
    @Log(title = "局部热处理实时数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MonitorPart monitorPart)
    {
        List<MonitorPart> list = monitorPartService.selectMonitorPartList(monitorPart);
        ExcelUtil<MonitorPart> util = new ExcelUtil<MonitorPart>(MonitorPart.class);
        return util.exportExcel(list, "局部热处理实时数据数据");
    }

    /**
     * 新增局部热处理实时数据
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存局部热处理实时数据
     */
    @RequiresPermissions("monitor:part:add")
    @Log(title = "局部热处理实时数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MonitorPart monitorPart)
    {
        return toAjax(monitorPartService.insertMonitorPart(monitorPart));
    }

    /**
     * 修改局部热处理实时数据
     */
    @RequiresPermissions("monitor:part:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MonitorPart monitorPart = monitorPartService.selectMonitorPartById(id);
        mmap.put("monitorPart", monitorPart);
        return prefix + "/edit";
    }

    /**
     * 修改保存局部热处理实时数据
     */
    @RequiresPermissions("monitor:part:edit")
    @Log(title = "局部热处理实时数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MonitorPart monitorPart)
    {
        return toAjax(monitorPartService.updateMonitorPart(monitorPart));
    }

    /**
     * 删除局部热处理实时数据
     */
    @RequiresPermissions("monitor:part:remove")
    @Log(title = "局部热处理实时数据", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(monitorPartService.deleteMonitorPartByIds(ids));
    }
}
